package com.example.demo.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serial;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 菜单表
 * @TableName menu
 */

@Schema(description = "菜单信息")
@EqualsAndHashCode(callSuper = true)
@TableName(value ="menu")
@Data
public class Menu extends BaseEntity implements Serializable {

    @Schema(description = "父id")
    private Long parentId;

    @Schema(description = "菜单码")
    private String name;

    @Schema(description = "菜单标题")
    private String title;

    @Schema(description = "组件路径")
    private String component;

    @Schema(description = "跳转路径")
    private String path;

    @Schema(description = "重定向路径")
    private String redirect;

    @Schema(description = "排序序号")
//    private Integer rank;           // rank关键字在mysql8中有特色含义，因此不能作为字段使用
    private Integer sortValue;

    @Schema(description = "菜单图标名")
    private String icon;

    @Schema(description = "是否无需页面缓存页面")
    private Integer noKeepAlive;

    @Schema(description = "是否不显示该菜单项")
    private Integer noInMenu;

    @Schema(description = "是否隐藏菜单")
    private Integer hiddenMenu;

    @Schema(description = "是否隐藏布局")
    private Integer hiddenLayout;

    @Schema(description = "是否固定在标签页")
    private Integer affix;

    @Schema(description = "是否跳往外部链接")
    private Integer link;

    @Schema(description = "状态(0:禁止,1:正常)")
    private Integer status;

    @Schema(description = "可执行的操作")
    @TableField(exist = false)
    private String actions;

    @Schema(description = "子节点")
    @TableField(exist = false)
    private List<Menu> children;

    @Serial
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public static final Long rootId  = 1L;
    public static final String id_key  ="id";
    public static final String parentId_key  = "parentId";
    public static final String sort_key  = "rank";

    public static String entityTitle="菜单";

    public static Map<String,String> getExcelCols(){
        Map<String,String> map=new LinkedHashMap<>();
        map.put("parentId","父级id");
        map.put("name","菜单码");
        map.put("title","菜单标题");
        map.put("component","组件路径");
        map.put("path","跳转路径");
        map.put("redirect","重定向路径");
        map.put("sortValue","排序序号");
        map.put("icon","菜单图标");
        map.put("noKeepAlive","是否无需缓存页面");
        map.put("noInMenu","是否不显示该菜单项");
        map.put("hiddenMenu","是否隐藏菜单");
        map.put("hiddenLayout","是否隐藏布局");
        map.put("affix","是否固定在标签页");
        map.put("link","是否跳往外部链接");
        map.put("hasChildren","是否存在子节点");
        map.put("status","状态");
        return map;
    }
}